/**     
 * @Title: DefaultExceptionHandler.java   
 * @Package com.zhfd.common.spring.handler   
 * @Description: TODO
 * @author weiwei 
 * @date 2017年10月30日 上午9:19:55   
 * @version V1.0     
 */
package com.xnkf.common.spring.handler;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.servlet.HandlerExceptionResolver;
import org.springframework.web.servlet.ModelAndView;

import com.xnkf.common.util.ReqUtils;
import com.xnkf.common.util.RetCode;

/**
 * @ClassName: DefaultExceptionHandler
 * @Description: TODO
 * @author weiwei
 * @date 2017年10月30日 上午9:19:55
 * 
 */
public class DefaultExceptionHandler implements HandlerExceptionResolver {

	private final static Logger LOG = LoggerFactory.getLogger(DefaultExceptionHandler.class);

	@Override
	public ModelAndView resolveException(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) {
		ModelAndView mv = new ModelAndView();
		ReqUtils.writeError(RetCode.SYSERROR, "服务器在开小差，请稍后再试", response);
		LOG.error("异常:" + ex.getMessage(), ex);
		return mv;
	}
}